package java_thinking.unit_17;

import java_thinking.unit_17._17_2_6.Countries;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * @Desc:   创建一个ArrayList and a LinkedList 用Countries.names()生成器来填充每个容器
 *          ，用普通的Iterator打印每个列表，然后用ListIterator按隔一个位置掺入一个对象的方式
 *          把一个表插入到另一个表中，现在，从第一个表的末尾开始，向前移动执行插入操作
 * @author: cww
 * @DateTime: 2019/4/15 20:22
 */

public class E07_CrossInsertion {
    public static void main(String[] args) {
        List<String> strings = new ArrayList<>(Countries.names(10));
        List<String> l1 = new LinkedList<>(Countries.names(20).subList(10,19));
        for (Iterator<String> it = strings.iterator();it.hasNext();) {
            System.out.println(it.next());
        }
        System.out.println("***********");
        for (Iterator<String> it = l1.iterator();it.hasNext();) {
            System.out.println(it.next());
        }
        int alindex = 0;
        for (Iterator<String> it3 = l1.iterator();it3.hasNext();) {
            strings.add(alindex,it3.next());
            alindex +=2;
        }
        System.out.println("strings = "+strings);

    }
}
